package com.umakr.ax.app.web;

import java.util.Date;
import java.util.Map;

import com.umakr.ax.app.service.SpreadWebService;
import com.umakr.ax.common.service.SpreadService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.ui.ModelMap;
import com.umakr.ax.common.model.Spread;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import com.umakr.ax.core.base.AbstractController;

/**
 * <p>
 * 电台推广  前端控制器
 * </p>
 *
 * @author Umakr-Code-Generator
 * @since 2017-12-30
 */
@Controller
@RequestMapping("/api/web/spread")
public class SpreadWebController extends AbstractController {
	@Autowired
	SpreadWebService spreadWebService;

	@ApiOperation(value = "软删除删除广告/直播")
	@GetMapping("/delSpread")
	@ResponseBody
	public Object delSpread(ModelMap modelMap,@RequestParam(name = "id") Long id, @RequestParam(name = "spreadStatus") Integer spreadStatus) {
		return setSuccessModelMap(modelMap,spreadWebService.delSpread(id,spreadStatus));
	}

	@ApiOperation(value = "广告/直播列表 0 广告 1 直播")
	@GetMapping("/listSpreadByType")
	@ResponseBody
	public Object listSpreadByType(ModelMap modelMap,Long rsId, Integer spreadType) {
		return setSuccessModelMap(modelMap,spreadWebService.listSpreadByType(rsId,spreadType));
	}

	@ApiOperation(value = "摇直播，广告列表")
	@GetMapping("/listSpreadForShake")
	@ResponseBody
	public Object listSpreadForShake(ModelMap modelMap,@RequestParam(name = "rsId") Long rsId, @RequestParam(name = "spreadType") Integer spreadType,String searchText) {
		return setSuccessModelMap(modelMap,spreadWebService.listSpreadForShake(rsId,spreadType,searchText));
	}

	@ApiOperation(value = "发布摇一摇广告/直播")
	@PostMapping("/saveOrUpdateSpread")
	@ResponseBody
	public Object saveOrUpdateSpread(ModelMap modelMap, Spread spread ,String spreadUrl,Long resultContentId ) {
		return setSuccessModelMap(modelMap,spreadWebService.saveOrUpdateSpread(spread,spreadUrl,resultContentId));
	}

	@ApiOperation(value = "根据id获取推广信息")
	@GetMapping("/getSpreadInfoById")
	public Object getSpreadInfoById(ModelMap modelMap, Long spreadId ) {
		return setSuccessModelMap(modelMap,spreadWebService.getSpreadInfoById(spreadId));
	}
}